package com.example.yuejianapp14.Activity.Fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.yuejianapp14.Activity.Adapter.ClubVideoAdapter;
import com.example.yuejianapp14.Activity.JavaBean.Video1;
import com.example.yuejianapp14.Activity.Listener.VideoListener;
import com.example.yuejianapp14.Activity.Model.VideoModel;
import com.example.yuejianapp14.R;

import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClubVideoFragment extends Fragment {
    private RecyclerView recyclerView;
    private List mDataList;
    private View view;

    public ClubVideoFragment() {
        // Required empty public constructor
    }
    VideoListener videoListener = new VideoListener() {
        @Override
        public void onResponse(List<Video1> beanList) {
            mDataList=beanList;
            ClubVideoAdapter adapter = new ClubVideoAdapter(getActivity(),mDataList);
            recyclerView.setAdapter(adapter);
        }

        @Override
        public void onFail(String msg) {

        }
    };


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view= inflater.inflate(R.layout.fragment_club_video, container, false);
        initRecyclerView();
        getData();
        return view;
    }
    private void getData() {
        Intent intent = getActivity().getIntent();
        VideoModel videoModel =new VideoModel();
        videoModel.findVideo(intent.getStringExtra("clubid"),videoListener);
    }
    private void initRecyclerView() {
        recyclerView = (RecyclerView) view.findViewById(R.id.rv);
        recyclerView.setLayoutManager(new LinearLayoutManager((this.getActivity())));
        recyclerView.setItemAnimator(new DefaultItemAnimator());

    }

}
